package com.hzf.wxplatform.web.controller.manager.owner;

import com.github.wenhao.geohash.GeoHash;
import com.hzf.api.rpc.api.ApiService;
import com.hzf.common.base.BaseController;
import com.hzf.common.util.*;
import com.hzf.config.dao.model.*;
import com.hzf.designer.dao.model.*;
import com.hzf.order.dao.model.OrderUser;
import com.hzf.order.dao.model.OrderUserDemand;
import com.hzf.order.dao.model.OrderUserInfo;
import com.hzf.ucenter.dao.model.UcenterUser;
import com.hzf.wxplatform.common.WxplatformResult;
import com.hzf.wxplatform.common.WxplatformResultConstant;
import com.hzf.wxplatform.common.utils.UcenterUserUtils;
import com.megvii.cloud.mylibrary.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/ownerDemand")
public class OwnerDemandController  extends BaseController{
    @Autowired
    ApiService apiService;
    @RequestMapping(value="/ownerSaveDesigner")
    public  String ownerSaveDesigner(Model model, HttpServletRequest request){
        String key = "style";
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        ConfigRegion configRegion = new ConfigRegion();
        byte[] user = UcenterUserUtils.getUser(session);
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        byte[] address = UcenterUserUtils.getAddress(ucenterUser.getId());
        configRegion = (ConfigRegion) ByteUtils.ByteToObject(address);
        byte[]styleListByte = RedisUtil.get(key.getBytes());
        List<ConfigStyle> list =JsonListUtil.jsonToList( RedisUtil.get(key),ConfigStyle.class);
        if(null!=list&&0!=list.size()){
            model.addAttribute("styleList",list);

        }else{
            ConfigStyleExample example = new ConfigStyleExample();
            list = apiService.selectByConfigStyleExample(example);
            RedisUtil.del_add(key,JsonListUtil.listToJson(list));
            model.addAttribute("styleList",list);
        }

        model.addAttribute("configRegion",configRegion);
        DneedsDemand dneedsDesigner = (DneedsDemand)EhCacheUtil.get("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu");
        if(null!=dneedsDesigner){
            if(dneedsDesigner.getStyleAnli()!=0&&dneedsDesigner.getStyleAnli()!=null){
                ConfigPtanliExample configPtanliExample = new ConfigPtanliExample();
                configPtanliExample.createCriteria().andIdEqualTo(dneedsDesigner.getStyleAnli());
                ConfigPtanli configPtanli = apiService.selectConfigPtanliRegion(configPtanliExample);
                model.addAttribute("configPtanli",configPtanli);
            }
            else{

            }
            System.out.println(dneedsDesigner.getCallName());

            model.addAttribute("dneedsDesigner",dneedsDesigner);
            model.addAttribute("type",1);
        }else{
            model.addAttribute("type",0);

        }

        return  thymeleaf("/SJS/SJS_FBXQD");
    }
    @RequestMapping(value="/ownerSaveDemand",method = RequestMethod.POST)
    @ResponseBody
    public Object ownerSaveDemand(Model model,DneedsDemand dneedsDemand,HttpServletRequest request){
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        ConfigRegion configRegion = new ConfigRegion();
        byte[] user = UcenterUserUtils.getUser(session);
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        byte[] address = UcenterUserUtils.getAddress(ucenterUser.getId());
        configRegion = (ConfigRegion) ByteUtils.ByteToObject(address);
        dneedsDemand.setCity(configRegion.getRegionId());
        dneedsDemand.setCreateDate(new Date());
        dneedsDemand.setUpdateTime(new Date());
        dneedsDemand.setDemandType(0);
        dneedsDemand.setUserId(ucenterUser.getId());
        GeoHash geoHash = GeoHash.fromCoordinate(dneedsDemand.getLat(),dneedsDemand.getLng());
        //4024744861876082L
        long longValue = geoHash.toLong();
        dneedsDemand.setGeoCode(longValue);
        apiService.installDneedsDemand(dneedsDemand);
        return new WxplatformResult(WxplatformResultConstant.SUCCESS, "保存成功");
    }
    @RequestMapping(value="/ownerStyle",method = RequestMethod.POST)
    @ResponseBody
    public Object ownerStyle(Model model,DneedsDemand dneedsDemand,HttpServletRequest request){
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        ConfigRegion configRegion = new ConfigRegion();
        byte[] user = UcenterUserUtils.getUser(session);
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        DneedsDemand dneedsDesigner = (DneedsDemand)EhCacheUtil.get("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu");
        if(null!=dneedsDesigner){
            EhCacheUtil.remove("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu");
        }
        EhCacheUtil.put("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu",dneedsDemand);
        return new WxplatformResult(WxplatformResultConstant.SUCCESS, "保存成功");
    }
    @RequestMapping(value = "/getStyle",method = RequestMethod.GET)
    public String getStyle(Integer id,Model model,HttpServletRequest request) throws Exception{
        String key = id+"anli";

        String  listByte = RedisUtil.get(key);
        ConfigStyleExample configStyleExample = new ConfigStyleExample();
        configStyleExample.createCriteria().andIdEqualTo(id);
        ConfigStyle configStyle = apiService.selectConfigStyleRegion(configStyleExample);

        List<ConfigPtanli> list =JsonListUtil.jsonToList(listByte,ConfigPtanli.class);
        if(null!=list&&0!=list.size()){
            model.addAttribute("result",list);
        }
        else{
            ConfigPtanliExample configPtanliExample = new ConfigPtanliExample();
            configPtanliExample.createCriteria().andStyleIdEqualTo(id);
            list = apiService.selectConfigPtanliExample(configPtanliExample);
            //简单粗暴,对于Map这句也适用
            String json = JsonListUtil.listToJson(list);
            RedisUtil.del_add(key,json);
        }
        model.addAttribute("configStyle",configStyle);
        model.addAttribute("result",list);

        return thymeleaf("/SJS/SJS_AnliXQing");


    }
    @RequestMapping(value = "/designerIndex/saveStyle",method = RequestMethod.POST)
    @ResponseBody
    private Object saveStyle(Model model,int id,HttpServletRequest request){
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        ConfigRegion configRegion = new ConfigRegion();
        byte[] user = UcenterUserUtils.getUser(session);
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        DneedsDemand dneedsDesigner = (DneedsDemand) EhCacheUtil.get("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu");
        dneedsDesigner.setStyleAnli(id);

        if(null!=dneedsDesigner){
            EhCacheUtil.remove("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu");
        }
        System.out.println(dneedsDesigner.getCallName());
        EhCacheUtil.put("hzf-wxplatform-web-ehcache",ucenterUser.getId()+"xuqiu",dneedsDesigner);
        return new WxplatformResult(WxplatformResultConstant.SUCCESS, "保存成功");

    }
    @RequestMapping(value="/xuanbiao",method = RequestMethod.POST)
    @ResponseBody
    private Object xuanbiao(int id,int bidId,Model model,HttpServletRequest request){
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        ConfigRegion configRegion = new ConfigRegion();
        byte[] user = UcenterUserUtils.getUser(session);
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
        dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
        DneedsDemand dneedsDemand =apiService.getDneedsDemand(dneedsDemandExample);
        if(null!=dneedsDemand&&null!=dneedsDemand.getCreateDate()){
            if(dneedsDemand.getDemandType()>1) {
                return new WxplatformResult(WxplatformResultConstant.FAILED, "已选标");

            }else{
                dneedsDemand.setDemandType(2);
                apiService.updateDneedsDemand(dneedsDemand);
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andIdEqualTo(bidId);
                DneedsBid dneedsBid = apiService.getDneedsBid(dneedsBidExample);
                dneedsBid.setState(1);
                apiService.updateDneedsBid(dneedsBid);
                DneedsBidExample dneedsBidExampleto= new DneedsBidExample();
                dneedsBidExampleto.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                List<DneedsBid>bidList = apiService.selectDneedsBid(dneedsBidExample);
                for(DneedsBid dneedsBid1 : bidList){
                    if(dneedsBid1.getId()==dneedsBid.getId()){
                    }else{
                        dneedsBid1.setState(3);
                        apiService.updateDneedsBid(dneedsBid1);
                    }
                }
                OrderUser orderUser = new OrderUser();
                orderUser.setAddress(dneedsDemand.getAddress());
                orderUser.setPhone(dneedsDemand.getCallPhone());
                orderUser.setOrderPayId(WeixinUtil.getRandomString(32));
                orderUser.setPayPrice(dneedsBid.getBidMoney().doubleValue());
                orderUser.setCreateTime(new Date());
                orderUser.setPayState(0);
                orderUser.setUserId(ucenterUser.getId());
                orderUser.setUserName(ucenterUser.getUserName());
                orderUser.setOrderState(1);
                orderUser = apiService.inserllOrder(orderUser);
                OrderUserDemand orderUserDemand = new OrderUserDemand();
                orderUserDemand.setDemandId(dneedsBid.getDemandId());
                orderUserDemand.setOrderUserId(orderUser.getId());
                orderUserDemand.setPayState(0);
                orderUserDemand.setPrice(dneedsBid.getBidMoney().doubleValue());
                orderUserDemand.setUserId(dneedsBid.getUserId());
                orderUserDemand.setCreateTime(System.currentTimeMillis());
                orderUserDemand.setReceivingState(0);
                apiService.installOrderUserDemand(orderUserDemand);
                return new WxplatformResult(WxplatformResultConstant.SUCCESS, "已选标");

            }
        }
        return new WxplatformResult(WxplatformResultConstant.SUCCESS, "已选标");

    }
    @RequestMapping(value="/sjtxq")
    private String sjtxq(int id,int type,HttpServletRequest request,Model model){
        byte[] user = UcenterUserUtils.getUser(request.getSession());
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }

       UcenterUser ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        DneedsDemand dneedsDemand= new DneedsDemand();
        if(type==1){  //业主查看
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid = apiService.getDneedsBid(dneedsBidExample);
                if(dneedsBid!=null){
                    DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                    dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/YZ/YZ_TB_SJT");
                }

            }

        }
        if(type==0){  //业主查看
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid = apiService.getDneedsBid(dneedsBidExample);
                if(dneedsBid!=null){
                    DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                    dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/YZ/YZ_TB_SJT");
                }

            }

        }
        if(type==2){//业主未付款
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                model.addAttribute("data",dneedsDemandSjt);
                model.addAttribute("type",type);
                return thymeleaf("/YZ/YZ_TB_SJT");
            }

        }
        if(type==3){//业主查看修改
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                model.addAttribute("data",dneedsDemandSjt);
                model.addAttribute("type",type);
                return thymeleaf("/YZ/YZ_TB_SJT");
            }

        }
        if(type==5){//设计师修改
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id);
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andUserIdEqualTo(ucenterUser.getId()).andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid =apiService.getDneedsBid(dneedsBidExample);
                if(null!=dneedsBid){
                    DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                    dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/SJS/SJS_XG_SJT");
                }


            }
        }
        if(type==6){//设计师查看
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id);
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andUserIdEqualTo(ucenterUser.getId()).andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid =apiService.getDneedsBid(dneedsBidExample);
                if(null!=dneedsBid){
                    DneedsDemandSjtExample dneedsDemandSjtExample = new DneedsDemandSjtExample();
                    dneedsDemandSjtExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandSjt dneedsDemandSjt = apiService.getDneedsDemandSjt(dneedsDemandSjtExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/YZ/YZ_TB_SJT");
                }


            }
        }

        model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
        return thymeleaf("/404");
    }

    @RequestMapping(value="/sjtxg")
    private String sjtxg(int id,int type,HttpServletRequest request,Model model){
        byte[] user = UcenterUserUtils.getUser(request.getSession());
        if (null == user) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }

        UcenterUser ucenterUser = (UcenterUser) ByteUtils.ByteToObject(user);
        if (null == ucenterUser) {
            model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
            return thymeleaf("/404");
        }
        DneedsDemand dneedsDemand= new DneedsDemand();
        if(type==1){  //业主查看
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid = apiService.getDneedsBid(dneedsBidExample);
                if(dneedsBid!=null){
                    DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                    dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/YZ/YZ_TB_WLT");
                }

            }

        }
        if(type==0){  //业主查看
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid = apiService.getDneedsBid(dneedsBidExample);
                if(dneedsBid!=null){
                    DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                    dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/YZ/YZ_TB_WLT");
                }

            }

        }
        if(type==2){//业主未付款
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                model.addAttribute("data",dneedsDemandSjt);
                model.addAttribute("type",type);
                return thymeleaf("/YZ/YZ_TB_WLT");
            }

        }
        if(type==3){//业主查看修改
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id).andUserIdEqualTo(ucenterUser.getId());
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                model.addAttribute("data",dneedsDemandSjt);
                model.addAttribute("type",type);
                return thymeleaf("/YZ/YZ_TB_WLT");
            }

        }if(type==5){//设计师修改
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id);
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andUserIdEqualTo(ucenterUser.getId()).andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid =apiService.getDneedsBid(dneedsBidExample);
                if(null!=dneedsBid){
                    DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                    dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/SJS/SJS_XG_WLT");
                }


            }
        }
        if(type==6){//设计师修改
            DneedsDemandExample dneedsDemandExample = new DneedsDemandExample();
            dneedsDemandExample.createCriteria().andIdEqualTo(id);
            dneedsDemand = apiService.getDneedsDemand(dneedsDemandExample);
            if(null!=dneedsDemand){
                DneedsBidExample dneedsBidExample = new DneedsBidExample();
                dneedsBidExample.createCriteria().andUserIdEqualTo(ucenterUser.getId()).andDemandIdEqualTo(dneedsDemand.getId()).andStateEqualTo(1);
                DneedsBid dneedsBid =apiService.getDneedsBid(dneedsBidExample);
                if(null!=dneedsBid){
                    DneedsDemandWltExample dneedsDemandWltExampleExample = new DneedsDemandWltExample();
                    dneedsDemandWltExampleExample.createCriteria().andDemandIdEqualTo(dneedsDemand.getId());
                    DneedsDemandWlt dneedsDemandSjt = apiService.getDneedsDemandWlt(dneedsDemandWltExampleExample);
                    model.addAttribute("data",dneedsDemandSjt);
                    model.addAttribute("type",type);
                    return thymeleaf("/SJS/YZ_TB_WLT");
                }


            }
        }


        model.addAttribute("data", "您的操作属于非法操作，所查看商品或设计师非您账户，请核实。");
        return thymeleaf("/404");
    }

}
